import { defineStore } from 'pinia'
import { CommonInterface } from "@/interface"

export const useCommonStore = defineStore('common', {
  state: (): CommonInterface.UseCommonState => ({
    requestTimes: 0
  }),
  getters: {
    isLoading(state) {
      return state.requestTimes > 0
    }
  },
  actions: {
    incrementRequestTimes() {
      this.requestTimes++
    },
    decreaseRequestTimes() {
      this.requestTimes--
    },
    resetRequestTimes() {
      this.requestTimes = 0
    }
  }
})